#coding-utf-8
#@Time    : 2019/3/3 17:09
#@Author  : 刘云
#@Email   : wnliuyun@126.com
#@File    : test.py
#@Software: PyCharm


import matplotlib.pyplot as plt
import cv2



class ImageProcss:
    def __init__(self, filePath):
        self.filePath = filePath
        #  获取图片数据
        self.data=cv2.imread(self.filePath, cv2.IMREAD_COLOR)

    def originalShow(self):
        # 显示图像
        cv2.imshow("original",self.data)

    def bgrSplitShow(self):
        #分解图像，默认顺序是BGR
        (B, G, R) = cv2.split(self.data)
        BB=cv2.merge()
        cv2.imshow("B", B)
        cv2.imshow("G", G)
        cv2.imshow("R", R)

    def hsvSplitShow(self):
        # 实现RGB颜色向HSV颜色空间的转换
        lena_hsv = cv2.cvtColor(self.data, cv2.COLOR_BGR2HSV)
        # 分解获得HSV分量
        (H, S, V) = cv2.split(lena_hsv)
        cv2.imshow("H", H)
        cv2.imshow("S", S)
        cv2.imshow("V", V)

filePath="C:\\Users\\yun\\Desktop\\baboon.jpg"
imageProcess =  ImageProcss(filePath)
imageProcess.originalShow()
imageProcess.bgrSplitShow()
imageProcess.hsvSplitShow()
cv2.waitKey(0)
cv2.destroyAllWindows()

# lena=cv2.imread("C:\\Users\\yun\\Desktop\\3.png")
# #高斯平滑滤波
# lena_Guassian= cv2.GaussianBlur(lena,(5,5),0)
# #获取图片尺寸
#  x,y=lena.shape[0:2]
# #缩放到原来的二分之一，输出尺寸格式为（宽，高）
# lena_resize=cv2.resize(lena,(int(y/2),int(x/2)))
# #缩放到原来的四分之一
# lena_4=cv2.pyrDown(lena_resize)
# #获取灰度图
# lena_gray=cv2.cvtColor(lena,cv2.COLOR_BGR2GRAY)
# #获取非黑即白的二值图像
# ret,lena_threshold=cv2.threshold(lena_gray,120,255,cv2.THRESH_BINARY)
# #
# cv2.imshow("original",lena)
# # cv2.imshow("Guassian",lena_Guassian)
# #
# # cv2.imshow("1/2",lena_resize)
# # cv2.imshow("1/4",lena_4)
# # cv2.imshow("gray",lena_gray)
# # cv2.imshow("threshold",lena_threshold)











